package ${serviceImplPackageName};

import ${entityPackageName};
import top.v5it.japi.ddd.core.dao.impl;

import cn.hutool.core.lang.Assert;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.util.List;

@Slf4j
@Service(${classServiceName}.SERVICE_NAME)
public class ${className} extends BasicServiceImpl<BasicDaoJdbcImpl> implements ${classServiceName} {

    /**
    * 根据主键查找
    *
    * @param id
    * @return
    */
    @Override
    public ${entityName} searchById(Long id) {
        Assert.notNull(id, "请求id不能为空");
        return basicDao.load(id, new ${entityName}());
    }

    /**
    * 修改
    *
    * @param entity
    */
    @Override
    public void modify(${entityName} entity) {
        Assert.notNull(entity, "请求参数[entity]不能为空");
        basicDao.update(entity);
    }

    /**
    * 新增
    *
    * @param entity
    */
    @Override
    public void add(${entityName} entity) {
        Assert.notNull(entity, "请求参数[entity]不能为空");
        basicDao.insert(entity);
    }

    /**
    * 批量新增或修改，不存在新增，存在则修改
    *
    * @param entities
    */
    @Override
    public void batch(List<${entityName}> entities) {
        Assert.notNull(entity, "请求参数[entities]不能为空");
        basicDao.insertOrUpdateForList(entities);
    }
}